#pragma once


// CSideviewCtrl

typedef struct
{
	HBITMAP	hDib;
	PBYTE	pRaster;
	DWORD	dwSize;
} USER_BITMAP, *PUSER_BITMAP;

PUSER_BITMAP createBitmap(int cx, int cy);
void drawBitmap(PUSER_BITMAP pUB, HDC hDC, int x, int y);
void destroyBitmap(PUSER_BITMAP pUB);


class CSideviewCtrl : public CStatic
{
	DECLARE_DYNAMIC(CSideviewCtrl)

public:
	CSideviewCtrl(int cx=100, int cy=25);
	virtual ~CSideviewCtrl();

	void setSize(int cx, int cy);
	void setData(DWORD dwPos, BYTE bLen, BYTE *pData);
	void drawData(DWORD dwSize);
	void clear(void);

	// 0 <= bLine < 5
	WORD getLineData(BYTE bLine, BYTE **ppData);

	void setThreshold(BYTE bLevel);
	BYTE getThreshold(void);

private:
	CRect				m_rect;
	CSize				m_size;
	DWORD				m_dwImgSize;
	PBYTE				m_pImgBuf;
	PBYTE				m_pLineBuf;
	PUSER_BITMAP		m_pUserBmp;

	BYTE				m_bThreshold;
	WORD				m_wCheckSum;

protected:
	DECLARE_MESSAGE_MAP()
	virtual void PreSubclassWindow();
public:
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnPaint();
};
